{extend name="./template/default/pc/pub/base.html" /}
{block name="seo"}
<title>个人书架-{$site_name}</title>
{/block}
{block name="content"}
<main class="container mt30 mb20 overflow-Show clearfix" style="min-height:750px;">
    {include file="./template/default/pc/pub/uc_menu.html"}
    <article class="article-main pull-right">
        <section class="box">
            <header class="box-header">
                <span class="title">我的书架</span>
                <ul class="box-simple-tabs">
                    <li><a class="active" href="/bookshelf">我的收藏</a></li>
                    <li><a href="/history">阅读记录</a></li>
                </ul>
                <div class="pull-right">
                    <a href="#" class="more js_edit_booklist_btn">
                        <i class="icon icon-box mr5"></i>整理我的收藏</a>
                    <div href="#" class="box-booklist-edit-head" style="display: none">
                        <form>
                            <span>
                                <button id="book_del" type="button" class="del-btn">删除</button>
                            </span>
                            <input id="url_param" type="hidden" value="delfavors"></input>
                            <span>
                                <button type="button" class="finish-btn js_esc_booklist_btn">完成</button>
                            </span>
                            <input name="uid" type="hidden" value="274756461">
                        </form>
                    </div>
                </div>
            </header>
            <div class="box-body">
                <div class="bg-gray box-sub-head clearfix">
                    <dl class="box-head-sort pull-left"> <dt>排序:</dt>
                        <dd style="cursor: pointer;color: #fd113a;" data-sort="1">未读更新<i class="icon icon-d-caret"></i></dd>
                        <dd style="cursor: pointer;" data-sort="3">更新时间<i class="icon icon-d-caret"></i></dd>
                        <dd style="cursor: pointer;" data-sort="6">阅读时间<i class="icon icon-d-caret"></i></dd>
                    </dl>
                    <div class="pull-right">
                        <span class="search-input">
                            <input name="title" type="text" class="" value="" placeholder="请输入作品名称">
                            <button type="button" name="btnsearch">
                                <i class="icon icon-search"></i>
                            </button>
                        </span>
                    </div>
                </div>
                <div class="mt20">
                    <ul class="mh-list col7">
                        {raccoon:favors name="favors" where="user_id='$xwx_user_id'"}
                        <li>
                            <div class="mh-item">
                                <a href="/{$book_ctrl}/{$vo.book.param}" class="mh-cover" style="background-image: url({$vo.book.cover_url})">
                                    <span class="tag  mh-tag">{$vo.book.end?"完结":"连载"}</span>
                                    <span class="read-section">{$vo.book.last_time|date='Y-m-d'}更新</span>
                                    <span mid="{$vo.book.id}" class="edit-state">
                                        <i class="icon icon-ok"></i>
                                    </span>
                                </a>
                                <div class="mh-item-detali">
                                    <h2 class="title" style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
                                        <a href="/{$book_ctrl}/{$vo.book.param}">{$vo.book.book_name}</a>
                                    </h2>
                                    <p class="chapter" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">
                                        <a href="/{$book_ctrl}/{$vo.book.param}" target="_blank">{$vo.book.summary|subtext=12}</a>
                                    </p>
                                </div>
                            </div>
                        </li>
                        {/raccoon:favors}
                    </ul>
                </div>
            </div>
            <footer>
                <div class="page-pagination mt20">
                    <ul>
                        <div class="pagination">
                            {if $page.last_page > 1}
                            {if $page.current_page == 1}
                            <li><a>&lt;</a></li>
                            {else/}
                            <li><a id="prevPage" href="/bookshelf?page={$page.current_page-1}{$param}" title="上一页">&lt;</a></li>
                            {/if}

                            {for start="1" end="$page.last_page + 1"}
                            {if $i == $page.current_page }
                            <li><a href="/bookshelf?page={$i}{$param}" class="active">{$i}</a></li>
                            {else/}
                            <li><a href="/bookshelf?page={$i}{$param}" title="第{$i}页">{$i}</a></li>
                            {/if}
                            {/for}

                            {if $page.current_page == $page.last_page}
                            <li><a>&gt;</a></li>
                            {else/}
                            <li><a id="nextPage" href="/bookshelf?page={$page.current_page+1}{$param}" title="下一页">&gt;</a></li>
                            {/if}
                            {/if}
                        </div>
                    </ul>
                </div>
            </footer>
        </section>
    </article>
    <input id="hidCount" type="hidden" value="0">
</main>
<script>
    $(document).ready(function () {
        // 选择
        $('span.edit-state').click(function (ev) {
            ev.stopPropagation();
            ev.preventDefault();
            var $item = $(this)
            $item.hasClass('active') ? $item.removeClass('active') : $item.addClass('active')
        });


        // 显
        $('.js_edit_booklist_btn').click(function (ev) {
            ev.stopPropagation();
            ev.preventDefault();
            $(this).hide();
            $('.box-booklist-edit-head').show();
            $('span.edit-state').show();
        })
        // 隐
        $('.js_esc_booklist_btn').click(function (ev) {
            ev.stopPropagation();
            ev.preventDefault();
            $('.box-booklist-edit-head').hide();
            $('.js_edit_booklist_btn').show();
            $('span.edit-state').removeClass('active').hide();
            $('.js_allsel_checkbox').prop('checked', false);
        })

        $("#book_del").click(function () {
            var arr = $('span.edit-state.active');
            if (arr.length > 0) {
                $.ajax({
                    url: '/delfavors',
                    data: {ids: str},
                    type: 'POST',
                    dataType:'json',
                    success:function(res){
                        if (res.err === "0") {
                            ShowDialog(res.msg);
                        } else {
                            ShowDialog(res.msg);
                        }
                    }
                });

            } else {
                ShowDialog("请选择要删除的收藏或历史记录");
            }
            setTimeout(function () {
                location.reload();
            },2);
        });
    })

</script>
{/block}